package com.Cfeng.XiaohuanChat.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.time.LocalDateTime;

/**
 * @author Cfeng
 * @date 2022/8/3
 * 封装ChatMessage数据类，指定消息的类型，内容和发送者
 */

@Accessors(chain = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Document //MongoDB管理
public class ChatMessage {

    @Id
    private String id;
    //聊天消息的发送者
    private String sender;
    //消息接收者
    private String receiver;
    //消息内容
    private String content;
    //消息类型
    private MessageType type;

    //消息的创建时间
    private LocalDateTime createTime;


    //内部枚举类，封装消息类型： 聊天，加入，离开
    public enum MessageType {
        CHAT,
        JOIN,
        LEAVE
    }
}
